package com.kaishengit.web;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kaishengit.dao.GoalDao;
import com.kaishengit.dao.ProjectDao;
import com.kaishengit.entity.Goal;
import com.kaishengit.entity.Project;

public class GoalServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		int projectid = Integer.parseInt(request.getParameter("projectid"));
		GoalDao gdao = new GoalDao();
		Project p = new Project();
		ProjectDao pdao = new ProjectDao();
		p = pdao.findByProjectId(projectid);
		List<Goal> glist = new ArrayList<Goal>();
		glist = gdao.findByProjectId(projectid);
		request.setAttribute("goallist", glist);
		request.setAttribute("project", p);
		RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/views/goal.jsp");
		rd.forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	}

}
